# 写一个函数add_num函数，它是接收用户的输入两个数，并计算两个数的和

def add_num():
    # 用来接收第一个数
    first_num_str = input('请输入第一个数字：')  # '100'
    first_num = int(first_num_str)  # int函数，将字符串'100' 转换成int类型的100
    # 用来接收第一个数
    second_num_str = input('请输入第二个数字：')  # '20'
    second_num = int(second_num_str)  # int函数，将字符串'100' 转换成int类型的100

    # 计算它们的和并打印出来
    print(first_num + second_num)  # 期望120  实际'10020'

    # the_sum = first_num + second_num
    # print(the_sum)


# add_num()

if __name__ == '__main__':
    # add_num()
    # num_str = input('请输入一个数字：')
    # num = int(num_str)
    # print(type(num))
    # print(num)
    # 刚刚展示的是str -> int
    #
    # a = 23
    # print(type(a), a)
    # a_str = str(a)  # int 转成 str
    # print(type(a_str), a_str)

    # c = '42 for life'  # 字符串转int，需要字符串是数字的样式
    # c2 = '42'
    # c_int = int(c2)
    # print(c_int)

    # float > int
    # a = 2.1
    # print(type(a))
    # print(a)
    #
    # b = int(a)
    # print(type(b))
    # print(b)

    # a = '2.1'
    # print(a)
    # print(type(a))
    #
    # b = int(a)  # '2.1' 转不成int的
    # print(type(b))
    # print(b)

    # a = '2.1'
    # b = float(a)
    # c = int(b)
    # print(type(a), a)
    # print(type(b), b)
    # print(type(c), c)
    #
    # d = int(float(a))
    # print(d)
    # print(type(d))

    print(int(float('2.1')))  # 2
    print(float('2'))  # 2.0  float
    print(int(float('2')))  # 2 int
    print(float(2))  # 2.0
    print(int(float(2)))  # 2 int
